<template>
	<view class="Login">
		<!-- <u-button @getphonenumber="getuserinfo" open-type="getPhoneNumber">月落</u-button> -->
	</view>
</template>

<script>
	import { mapMutations } from "vuex"
	export default {
		data() {
			return {
				mobile: '',
				code: ''
			}
		},
		onLoad() {

		},
		methods: {
			...mapMutations({
				SET_openid: "config/SET_openid", // 系统的详细信息
			}),
			getuserinfo(res) {
				console.log(res);
			}
		},
		created() {
			let that = this;
			that.SET_openid("11111111111111");
					  uni.switchTab({
						  url: '/pages/findMusic/findMusic'
					  })
			//调用微信获取code
			wx.login({
			  success (res) {
			    if (res.code) {
			      //发起网络请求
				  that.$http.get("/auth.htm", {
					  jsCode: res.code,
					  appId: "wx1fb06d87038ead14",
					  secret: "6e835ec490a9ed65b7c59b58f937eb42",
					  // grantType: "authorization_code"
				  }).then(res => {
					  console.log(res);
					  // that.getUserInfo();
					  that.SET_openid(res.result.openid);
					  that.$Router.push({
						  name: "findMusic",
					  })
				  })
			    } else {
			      console.log('登录失败！' + res.errMsg)
			    }
			  }
			})
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
